package com.shop.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shop.shop.entity.Collect;
import com.shop.shop.mapper.CollectMapper;
import com.shop.shop.service.CollectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 收藏 服务实现类
 * </p>
 *
 * @author 小🌤
 * @since 2021-04-22
 */
@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> implements CollectService {

    @Override
    public Collect findByCmIdAndurId(Integer cmId, Object id) {
        QueryWrapper<Collect >collectQueryWrapper=new QueryWrapper<>();
        collectQueryWrapper.eq("cm_id",cmId);
        collectQueryWrapper.eq("ur_id",id);
        Collect one = getOne(collectQueryWrapper);
        return one;
    }

    @Override
    public int deletecmIdAndurId(Integer cmId, Object id) {
        QueryWrapper<Collect> collectQueryWrapper=new QueryWrapper<>();
        collectQueryWrapper.eq("cm_id",cmId);
        collectQueryWrapper.eq("ur_id",id);
        boolean remove = remove(collectQueryWrapper);
        return remove?1:0;
    }
}
